package o;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import com.huawei.appgallery.realname.impl.RealNameResponse;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.hmf.annotation.ApiDefine;
import java.lang.ref.WeakReference;
import o.cus.a;

@ApiDefine(uri = cut.class)
public class cur implements cut {
    private static String ˏ = "real_name_verify";
    private WeakReference<Activity> ˊ;
    private cku ˎ;
    private ProgressDialog ॱ;

    static abstract class c implements o.cus.b {
        private c() {
        }

        public a ˋ() {
            return new a().ˊ(4000000).ॱ(8);
        }
    }

    class b extends c {
        final /* synthetic */ cur ˏ;
        private cuu ॱ;

        public b(cur o_cur, cuu o_cuu) {
            this.ˏ = o_cur;
            super();
            this.ॱ = o_cuu;
        }

        public void ˏ(o.cus.b.d dVar) {
            cup.ˊ.ˋ("RealName", "phoneBinder PhoneBinderProcess BindPhoneResult:" + dVar);
            if (o.cus.b.d.SUCCESSED == dVar) {
                if (this.ॱ != null) {
                    this.ॱ.ˎ(1001);
                }
            } else if (o.cus.b.d.INTERRUPT != dVar) {
                Context context = (Context) this.ˏ.ˊ.get();
                if (context != null) {
                    ckv.ˎ(context.getString(o.cun.c.ˏ), 0);
                }
                if (this.ॱ != null) {
                    this.ॱ.ˎ(1000);
                }
            } else if (this.ॱ != null) {
                this.ॱ.ˎ(1000);
            }
        }
    }

    class d implements IServerCallBack {
        private cul ˊ;
        private WeakReference<Activity> ˎ;
        final /* synthetic */ cur ॱ;

        private d(cur o_cur, cul o_cul, Activity activity) {
            this.ॱ = o_cur;
            this.ˊ = o_cul;
            this.ˎ = new WeakReference(activity);
        }

        public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
        }

        public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
            this.ॱ.ॱ();
            if (!(responseBean instanceof RealNameResponse) || responseBean.getResponseCode() != 0 || responseBean.getRtnCode_() != 0) {
                if (this.ˎ != null) {
                    Context context = (Context) this.ˎ.get();
                    if (context != null) {
                        ckv.ˎ(context.getString(o.cun.c.ˏ), 0);
                    }
                }
                this.ˊ.ˊ(-1);
            } else if (((RealNameResponse) responseBean).ॱ() == 1) {
                cuz.ˏ().ॱ(cur.ˏ, true);
                this.ˊ.ˊ(1);
            } else {
                this.ˊ.ˊ(0);
            }
        }
    }

    private int ˋ() {
        if (!cuz.ˏ().ˋ(ˏ)) {
            return -1;
        }
        if (cuz.ˏ().ˊ(ˏ, false)) {
            return 1;
        }
        return 0;
    }

    public void ˊ(Activity activity, cul o_cul) {
        int ˋ = ˋ();
        if (ˋ == -1 || ˋ == 0) {
            ˎ((Context) activity);
            cvt o_cuw = new cuw();
            o_cuw.setServiceType_(cdh.ˎ(activity));
            cfw.ˎ(o_cuw, new d(o_cul, activity));
        } else if (o_cul != null) {
            o_cul.ˊ(1);
        }
    }

    private void ˎ(Context context) {
        if (this.ॱ == null) {
            this.ॱ = new ProgressDialog(context);
            this.ॱ.setMessage(cuo.ˎ().getString(o.cun.c.ˋ));
        }
        if (!(context instanceof Activity) || !cgt.ˋ((Activity) context)) {
            try {
                this.ॱ.show();
            } catch (Exception e) {
                cup.ˊ.ˊ("RealName", "showLoading error : " + e.toString());
            }
        }
    }

    private void ॱ() {
        try {
            if (this.ॱ != null && this.ॱ.isShowing()) {
                this.ॱ.dismiss();
            }
        } catch (IllegalArgumentException e) {
            cup.ˊ.ˊ("RealName", "stopLoading error : " + e.toString());
        }
        this.ॱ = null;
    }

    public void ˋ(Activity activity, final cuu o_cuu) {
        this.ˊ = new WeakReference(activity);
        if (!cgt.ˋ(activity)) {
            if (this.ˎ != null) {
                this.ˎ.dismiss();
                this.ˎ = null;
            }
            this.ˎ = cku.ˋ(activity.getString(o.cun.c.ˊ), activity.getString(o.cun.c.ॱ));
            this.ˎ.ॱ(new cks(this) {
                final /* synthetic */ cur ॱ;

                public void enableNetworking() {
                    this.ॱ.ˎ(o_cuu);
                }

                public void upgrade() {
                    o_cuu.ˎ(1000);
                }

                public void ˋ() {
                    o_cuu.ˎ(1000);
                }
            });
            this.ˎ.ˋ((Context) activity, "realname");
            this.ˎ.ॱ(-1, activity.getString(o.cun.c.ˎ));
        }
    }

    private void ˎ(cuu o_cuu) {
        if (this.ˊ != null) {
            Context context = (Context) this.ˊ.get();
            if (context != null) {
                new cus().ˎ(context, new b(this, o_cuu), true);
            }
        }
    }

    public void ˎ() {
        cuz.ˏ().ˎ(ˏ);
    }

    public void ˎ(Context context, cuq o_cuq) {
        cus.ˋ().ˏ(context.getApplicationContext(), new a(context, o_cuq));
    }
}
